package com.ruoyi.web.controller.wq;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.GameHomeService;
import com.ruoyi.wq.domain.WqGameHome;
import com.ruoyi.wq.domain.vo.WqGameHomeVO;
import com.ruoyi.wq.service.IWqGameHomeService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 固玩组队Controller
 * 
 * @author ruoyi
 * @date 2023-05-26
 */
@RestController
@RequestMapping("/wq/game")
public class WqGameHomeController extends BaseController {

    @Autowired
    private IWqGameHomeService wqGameHomeService;
    
    @Autowired
    private GameHomeService gameHomeService;

    /**
     * 查询固玩组队列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(WqGameHomeVO wqGameHome){
    	TableDataInfo info = wqGameHomeService.getPageList(wqGameHome);
        return info;
    }

    /**
     * 获取固玩组队详细信息
     */
    @Anonymous
    @GetMapping("/getInfo")
    public AjaxResult getInfo(String id) {
        return AjaxResult.success(wqGameHomeService.selectWqGameHomeById(id));
    }

    /**
     * 新增固玩组队
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WqGameHomeVO wqGameHome){
    	gameHomeService.addGameHome(wqGameHome);
        return AjaxResult.success();
    }
    
    /**
     * 新增固玩组队
     */
    @PostMapping("/join")
    public AjaxResult join(@RequestBody WqGameHomeVO wqGameHome){
    	gameHomeService.addJoin(wqGameHome);
        return AjaxResult.success();
    }

    /**
     * 修改固玩组队
     */
    @PreAuthorize("@ss.hasPermi('wq:game:edit')")
    @Log(title = "固玩组队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqGameHome wqGameHome)
    {
        return toAjax(wqGameHomeService.updateWqGameHome(wqGameHome));
    }

    /**
     * 删除固玩组队
     */
    @PreAuthorize("@ss.hasPermi('wq:game:remove')")
    @Log(title = "固玩组队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqGameHomeService.deleteWqGameHomeByIds(ids));
    }
}
